<?php
class o2o_task{
	 ceshi sourceTree
    function post_install($options){
        $channelLib = kernel::single('channel_interface_channel');
        $adapterLib = kernel::single('channel_interface_adapter');

        $data = array(
                'channel_bn'=>'移动端门店虚拟仓储',
                'channel_name'=>'移动端门店虚拟仓储',
                'channel_type'=>'wms',
                'node_id'=>'wap',
                'node_type'=>'wap',
        );
        $result = $channelLib->save($data);

        if ($result) {
            $channel_id = $data['channel_id'];
            $adapter_sdf = array(
                'channel_id' => $channel_id,
                'adapter' => 'wap',
            );
            $adapterLib->save($adapter_sdf);
        }

        unset($data, $adapter_sdf);

        $data = array(
                'channel_bn'=>'第三方POS门店虚拟仓储',
                'channel_name'=>'第三方POS门店虚拟仓储',
                'channel_type'=>'wms',
                'node_id'=>'webpos',
                'node_type'=>'webpos',
        );
        $result = $channelLib->save($data);

        if ($result) {
            $channel_id = $data['channel_id'];
            $adapter_sdf = array(
                'channel_id' => $channel_id,
                'adapter' => 'webpos',
            );
            $adapterLib->save($adapter_sdf);
        }

        $dlyCorpLib = kernel::single('ome_interface_dlycorp');
        $o2o_pickup_data = array(
            'type' => 'o2o_pickup',
            'name' => '门店自提',
            'd_type' => 2,
            'firstunit' => 0,#首重重量
            'firstprice' => 0,#首重费用
            'continueunit' => 0,#续重重量
            'continueprice' => 0,#续重费用
        );
        $save_dlycorp = $dlyCorpLib->save($o2o_pickup_data);

        $o2o_ship_data = array(
            'type' => 'o2o_ship',
            'name' => '门店配送',
            'd_type' => 2,
            'firstunit' => 0,#首重重量
            'firstprice' => 0,#首重费用
            'continueunit' => 0,#续重重量
            'continueprice' => 0,#续重费用
        );
        $save_dlycorp = $dlyCorpLib->save($o2o_ship_data);
        
        #自动插入线下服务端数据
        $serverObj    = app::get('o2o')->model('server');
        $type_list    = o2o_conf_server::getTypeList('wap');
        
        if($type_list)
        {
            $save_data    = array(
                    'server_bn'    => 'h5wap',
                    'name'    => $type_list['desc'],
                    'type'    => $type_list['type'],
                    'remote_url'    => '',
                    'sign_key'    => '',
            );
            $serverObj->save($save_data);
        }
    }

    function post_uninstall(){
        $channelLib = kernel::single('channel_interface_channel');
        $channelLib->delete(array('channel_type'=>'wms','node_type'=>array('wap','webpos')));
        $adapterLib = kernel::single('channel_interface_adapter');
        $adapterLib->delete(array('adapter'=>array('wap','webpos')));
        $dlyCorpLib = kernel::single('ome_interface_dlycorp');
        $dlyCorpLib->delete(array('type'=>array('o2o_pickup','o2o_ship'),'d_type'=>2));
    }

}
